AddCSLuaFile( "cl_init.lua" );
AddCSLuaFile( "shared.lua" );
 
include('shared.lua');

SIS = {};
	SIS.Trees = {
		"models/props/de_inferno/tree_large.mdl",
		"models/props/de_inferno/tree_small.mdl",
		"models/props_foliage/tree_deciduous_03a.mdl",
		"models/props_foliage/tree_deciduous_01a.mdl",
		"models/props_foliage/oak_tree01.mdl",
		"models/props_foliage/tree_cliff_01a.mdl",
		"models/props_foliage/tree_deciduous_01a-lod.mdl"
	};

	SIS.Rocks = {
		"models/props_wasteland/rockgranite02a.mdl",
		"models/props_wasteland/rockgranite02b.mdl",
		"models/props_wasteland/rockgranite02c.mdl",
		"models/props_wasteland/rockgranite03a.mdl",
		"models/props_wasteland/rockgranite03b.mdl",
		"models/props_wasteland/rockgranite03c.mdl",
		"models/props_wasteland/rockcliff01b.mdl",
		"models/props_wasteland/rockcliff01c.mdl",
		"models/props_wasteland/rockcliff01e.mdl",
		"models/props_wasteland/rockcliff01f.mdl",
		"models/props_wasteland/rockcliff01g.mdl",
		"models/props_wasteland/rockcliff01J.mdl",
		"models/props_wasteland/rockcliff01k.mdl",
		"models/props_wasteland/rockcliff05a.mdl",
		"models/props_wasteland/rockcliff05b.mdl",
		"models/props_wasteland/rockcliff05e.mdl",
		"models/props_wasteland/rockcliff05f.mdl",
		"models/props_wasteland/rockcliff06d.mdl",
		"models/props_wasteland/rockcliff06i.mdl",
		"models/props_canal/rock_riverbed01a.mdl",
		"models/props_canal/rock_riverbed01b.mdl",
		"models/props_canal/rock_riverbed01c.mdl",
		"models/props_canal/rock_riverbed01d.mdl",
		"models/props_canal/rock_riverbed02a.mdl",
		"models/props_canal/rock_riverbed02b.mdl",
		"models/props_canal/rock_riverbed02c.mdl",
		"models/props_wasteland/rockcliff_cluster01b.mdl",
		"models/props_wasteland/rockcliff_cluster02a.mdl",
		"models/props_wasteland/rockcliff_cluster02b.mdl",
		"models/props_wasteland/rockcliff_cluster02c.mdl",
		"models/props_wasteland/rockcliff_cluster03a.mdl",
		"models/props_wasteland/rockcliff_cluster03b.mdl",
		"models/props_wasteland/rockcliff_cluster03c.mdl",
		"models/props_wasteland/rockcliff05a.mdl"
	};
 
 function NodePickModel( Type )
	
	local model;
	
	if Type == "rock" then
		model = SIS.Rocks[ math.random( 1, #SIS.Rocks ) ];
	elseif Type == "tree" then
		model = SIS.Trees[ math.random( 1, #SIS.Trees ) ];
	else
		model = "models/props_junk/watermelon01.mdl";
	end
	
	return model;
end
 
function ENT:SpawnFunction(ply, tr)
	if (!tr.HitWorld) then return end
	if !ply:IsSuperAdmin() then return end;
	
	local ent = ents.Create("resource_node");
	ent:SetPos(tr.HitPos + Vector(0, 0, 50));
	ent:Spawn();
 
	return ent;
end

local ModelName = "";

function ENT:KeyValue( key, value ) 
	if key == "Type" then
		Type = value;
		self.Entity:SetNetworkedString( "Type", Type );
		ModelName = NodePickModel( Type );
	elseif key == "Size" then
		size = value;
		if size == "large" then
			ResourceAmmount = 100;
		elseif size == "medium" then
			ResourceAmmount = 50;
		elseif size == "small" then
			ResourceAmmount = 25;
		end
		self.Entity:SetNetworkedInt( "Ammount", ResourceAmmount );
	end
end
 
function ENT:Initialize()
	
	self.Entity:SetModel( ModelName );
	ModelName = "";
	self.Entity:PhysicsInit( SOLID_VPHYSICS ); 
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS ); 
	self.Entity:SetSolid( SOLID_VPHYSICS );    
	self.Entity:DrawShadow( true );
	self.Entity:SetCollisionGroup( COLLISION_GROUP_NONE );
	
    local phys = self.Entity:GetPhysicsObject();
	if (phys:IsValid()) then
		// never wake!
	end
end
 
function ENT:Use( activator, caller )

	return;

end
 
function ENT:Think()

	return;

end
